<template>
<div class="live-trade-detail">
  <!-- 3待支付、 4交易完成、 5交易关闭、6退款中、7退款成功 -->
  <!--<div class="type-block" v-if="subType > 2 && subType < 8">-->
    <!--<p class="top"><i class="iconfont icon-fanhui"></i>订单详情</p>-->
    <!--<p class="remain" v-if="subType === 3">剩余支付时间 {{ 12 }}</p>-->
    <!--<div class="middle waiting" v-if="subType === 3">-->
        <!--<div class="block">-->
            <!--<state-part></state-part>-->
        <!--</div>-->
        <!--<div class="block det">-->
            <!--<p class="tit">交易信息</p>-->
            <!--<info-part></info-part>-->
            <!--<div class="bot"></div>-->
            <!--<dealt-part></dealt-part>-->
        <!--</div>-->
        <!--<div class="block det">-->
            <!--<des-part></des-part>-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="middle" :class=" subType > 4 ?'confirm conFull':'confirm'" v-else>-->
      <!--<div class="block">-->
        <!--<state-part></state-part>-->
      <!--</div>-->
      <!--<div class="block det">-->
        <!--<p class="tit">交易信息</p>-->
        <!--<info-part></info-part>-->
      <!--</div>-->
      <!--<div class="block det" v-if="subType === 6 || subType === 7 ">-->
        <!--<p class="tit">退款详情</p>-->
        <!--<p class="bot marClear"><span class="txt-lab">退款总金额:</span><span class="txt-price black">￥{{ actual }}</span></p>-->
        <!--<p class="bot marClear"><span class="txt-lab">原路返回:</span><span class="txt-price">￥{{ actual }}</span></p>-->
      <!--</div>-->
      <!--<div v-if="subType > 2 && subType < 6 ">-->
          <!--<div class="block det">-->
              <!--<p class="tit">电子票</p>-->
              <!--<div class="e-ticket-block">-->
                  <!--<div>-->
                      <!--<p class="tit clear">电子票号：2736289273</p>-->
                      <!--<p class="tit clear">状态：<span class="blue">待使用</span></p>-->
                  <!--</div>-->
                  <!--<i class="iconfont icon-erweima"></i>-->
              <!--</div>-->
          <!--</div>-->
          <!--<div class="block det">-->
              <!--<p class="tit">订单明细</p>-->
              <!--<dealt-part></dealt-part>-->
          <!--</div>-->
          <!--<div class="block det">-->
              <!--<p class="tit marBotNeg">返 <span class="blue">268</span> 积分</p>-->
          <!--</div>-->
      <!--</div>-->
      <!--<div class="block det">-->
        <!--<des-part></des-part>-->
      <!--</div>-->
    <!--</div>-->
    <!--<div class="bottom" v-if="subType === 3">-->
      <!--<p class="btn cancel">取消订单</p>-->
      <!--<rotate to="pay">-->
          <!--<p class="btn ok">去支付</p>-->
      <!--</rotate>-->
    <!--</div>-->
    <!--<div class="bottom" v-if="subType === 4">-->
      <!--<p class="return mar">申请退款</p>-->
    <!--</div>-->
  <!--</div>-->
  <!-- 1支付确认 -->
  <div class="type-block">
    <p class="top"><z-history :type="1"></z-history>确认支付</p>
    <div>
        <div class="middle confirm">
            <div class="block det">
                <info-part :liveData = "liveData1"></info-part>
            </div>
            <div class="block det" v-if="isPoints">
                <div class="pointSwitch marBotNeg">
                    <span class="ps-left">积分   共124积分，可用50积分，抵¥1.00</span>
                    <span class="ps-right switch-on"><i></i></span>
                </div>
            </div>
            <div class="block det">
                <deal-part :order="oder1"></deal-part>
            </div>
        </div>
        <div class="bottom">
            <span class="txt">合计：￥{{ totalPrices }}</span>
            <p class="btn ok" @click="getTimer()">去支付</p>
        </div>
    </div>
    <!--<div v-if="payTime === 2">-->
        <!--<div class="middle confirm conFull">-->
            <!--<div class="block det">-->
                <!--<p class="pay-title">支付剩余时间</p>-->
                <!--<p class="pay-time">{{ timerEn }}</p>-->
                <!--<p class="bot"><span class="txt-lab">实付款:</span><span class="txt-price">￥{{ actual }}</span></p>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
  </div>
  <!-- 2申请退款 -->
  <!--<div class="type-block" v-if="subType == 2">-->
    <!--<p class="top"><i class="iconfont icon-fanhui"></i>申请退款</p>-->
    <!--<div class="middle confirm conFull">-->
      <!--<div class="block det">-->
        <!--<p class="tit">交易信息</p>-->
        <!--<info-part></info-part>-->
        <!--<p class="bot"><span class="txt-lab">退款金额:</span><span class="txt-price">￥{{ actual }}</span></p>-->
      <!--</div>-->
      <!--<div class="block det">-->
        <!--<p class="tit">退款原因<span class="red">*</span></p>-->
        <!--<textarea class="text-area" placeholder="请详细填写退款的原因，方便更快的给您通过审核"></textarea>-->
      <!--</div>-->
      <!--<div class="return-btnBig">提交申请</div>-->
    <!--</div>-->
  <!--</div>-->
</div>
</template>
<script type="text/ecmascript-6">
  /* 组件 */
  import infoPart from './info.vue'
  import statePart from './state.vue'
  import dealPart from './deal.vue'
  import dealtPart from './dealt.vue'
  import desPart from './des.vue'
  /* 页面用到的js */
  import {commonService} from '../../service/commonService'
  import {common} from '../../assets/js/common/common'
  export default {
    props: [],
    components: {
      'info-part': infoPart,
      'state-part': statePart,
      'deal-part': dealPart,
      'dealt-part': dealtPart,
      'des-part': desPart
    },
    data () {
      common.pageTitle('支付详情')
      return {
        type: this.$route.params.typ,/* 判断是哪个模块的支付；1：活动；2：知识；3：直播； */
        subType: 1, /* 判断当前订单的状态；1：确认支付；2：申请退款；3待支付、 4交易完成、 5交易关闭、6退款中、7退款成功 */
        actual: 0,// 实际支付金额
        isPoints: false, //是否使用积分
        timerEn: '',
        //timerZh: this.$store.state.tranStore.order.downCount,
        payTime: 1,
          No:'',
          liveData1:'',
          oder1:'',
          totalPrices:'',//实付金额
          key:'',
          shopid:'',
      }
    },
    created () {
      this.getInfo();
    },
//    mounted () {
//      this.getInfo();
//    },
    methods: {
      getInfo () {
        let that = this
        let type = that.type;
//        let obj = that.getOrderState(1,1,1)//获取
//        if(typ === 1){ /*活动*/

          commonService.getInfo().then(function (res) {
            that.liveData1 = res.data.datas;
            that.oder1 = res.data.datas;
            that.key = that.oder1.key;
            that.totalPrices = that.oder1.price - that.oder1.freeMoney;
//            that.$store.state.tranStore.order = obj2;
//            console.log(that.$store.state.tranStore.order)
            // 计算实际支付金额
//            let pri = obj.price;
//            let poi = that.$store.state.tranStore.order.points;
//            let fav = that.$store.state.tranStore.order.favorable;
//            let dis = that.$store.state.tranStore.order.discount;
//            let fre = that.$store.state.tranStore.order.freight;
//            let act = ( pri - poi - fav - dis + fre)
//              console.log(poi)
            /*that.$store[0].state.order.img.path = obj.img
            that.$store[0].state.order.img.width = 80
            that.$store[0].state.order.img.height = 80*/
//            that.subType = that.$store.state.tranStore.order.orderState
//            that.$store.state.tranStore.order.actualPay = act;
//            that.actual = act;
//            that.isPoints = poi > 0 ? 1 : 0;

            /*that.$watch('changeState', function () {
                console.log('watch', that.subType)
            })*/
          });
//        }else if(typ === 2){ /*知识*/
//          commonService.getInfo({ modTyp:'knowledge' }).then(function (res) {
//            console.log(res)
//          });
//        }else if(typ === 3){ /*直播*/
//          commonService.getInfo({ modTyp:'live' }).then(function (res) {
//            console.log(res)
//          });
//        }
//          getInfo () {
//              let that = this
//              liveService.getLiveInfo().then(function (res) {
//                  let obj = res.data.transaction.common;
//                  that.liveData.title = obj.title;
//                  that.liveData.img = obj.img;
//                  var newDate = new Date();
//                  newDate.setTime(obj.time*1000);
//                  that.liveData.date = common.getFormatOfDate( newDate , 'yyyy-MM-dd h:m:s');
//                  that.liveData.price = common.getFormatOfPrice(obj.price);
//              });
//          }
      },
//      getOrderState (typ, subType, isFavorable) {
//        if(typ === 1){ /*活动*/
//          typ = 'activity'
//        }else if(typ === 2){ /*知识*/
//          typ = 'knowledge'
//        }else if(typ === 3){ /*直播*/
//          typ = 'live'
//        }
//        if(subType === 1){ /*待支付*/
//          subType = 'aa'
//        }
//        else if(subType === 2){ /*确认支付*/
//          subType = 'bb'
//        }
//        else if(subType === 3){ /*交易完成*/
//          subType = 'cc'
//        }
//        else if(subType === 4){ /*交易关闭*/
//          subType = 'dd'
//        }
//        else if(subType === 5){ /*申请退款*/
//          subType = 'ee'
//        }
//        else if(subType === 6){ /*退款中*/
//          subType = 'ff'
//        }
//        else if(subType === 7){ /*退款成功*/
//          subType = 'gg'
//        }
//        if(isFavorable === 1){ /*会员优惠*/
//          isFavorable = 'hh'
//        }
//        else if(isFavorable === 2){ /*使用积分*/
//          isFavorable = 'ii'
//        }
//        else if(isFavorable === 3){ /*折扣*/
//          isFavorable = 'jj'
//        }
//        else if(isFavorable === 4){ /*运费*/
//          isFavorable = 'kk'
//        }
//        else if(isFavorable === 5){ /*无优惠活动*/
//          isFavorable = 'll'
//        }
//        return {
//          typ,
//          subType,
//          isFavorable
//        }
//      },
//      dateFormat (time, formatter) { // 时间格式
//            let newDate = new Date();
//            newDate.setTime(time*1000);
//          //return common.getFormatOfDate( newDate , 'yyyy-MM-dd h:m:s');
//          return common.getFormatOfDate( newDate , formatter);
//      },
//      moneyFormat () { // 金额格式
//          return common.getFormatOfPrice(obj.price);
//      },
      getTimer () {
//          let that = this
//          let timesamp = 1510329540000;
//          that.payTime = 2
//          setInterval(function () {
//              let timeGroup = common.getTimer(timesamp)
//              console.log('dd',timeGroup.dd)
//              let mm = timeGroup.dd*24*60 + timeGroup.hh*60 +  timeGroup.mm;
//              let ss = timeGroup.ss
//              that.timerEn = mm + ":"+ ss
//              //that.$store.state.tranStore.order.downCount = mm + "分"+ ss + "秒"
//
//          },1000)
          let that = this
          commonService.getOder({key:this.key}).then(function (res) {
              let type = res.data.datas.type;
              let orderNum = res.data.datas.orderNo;
              if(type === '1'){
                  //console.log('这里是免费的')
              }
              if(type === '2'){
                  that.$router.push({name:'pay',params:{orderNo:orderNum}})
              }
          })
      }

    },
//    watch: {
//      changeState (){
//        this.subType = this.$store.state.tranStore.order.orderState
//      }
//    }
  }
</script>
<style lang="less">
  @import "../../assets/css/component/transaction.less";
</style>